package com.nike.main;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.nike.dao.NikeDao;
import com.nike.thread.NikeEmailEditThread;
import com.nike.util.DeviceUtil;
import com.nike.util.IPFactory;
import com.nike.util.JDBCUtil;

public class NikeBuildUpdateMain {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Connection c = null;
		// TODO Auto-generated method stub
		try {
			Class.forName("com.mysql.jdbc.Driver");
			c = DriverManager.getConnection(JDBCUtil.jdbcStr);
			
			while(true) {
				try {
					NikeDao nikeDao = new NikeDao();
					List<Map<String,String>> sensorList = nikeDao.getSensorNoBuild(c);
					if(sensorList!=null && sensorList.size()>0) {
						for(Map<String,String> sensorMap : sensorList) {
							sensorMap.put("build_id", DeviceUtil.getAndroidId(6).toUpperCase());
							nikeDao.updateSensorData(sensorMap, c);
						}
					}else {
						break;
					}
					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			if(c!=null)
				try {
					c.close();
				} catch (SQLException e) {
				}
		}
	}

}
